package com.aratek.huwai.dao;

import com.aratek.huwai.model.DishEntity;
import com.aratek.huwai.model.ScoreEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author 姜寄羽
 * 料理保存相关
 * @Date 2018/1/22 17:27
 */
public interface ScoreRepository extends CrudRepository<ScoreEntity,String> {
    AtomicInteger KEY = new AtomicInteger(1);

    int countByDishIdAndRaterTable(Integer dishId, Integer raterTable);

    List<ScoreEntity> findScoreEntitiesByDishId(Integer dishId);

    @Modifying
    @Query("delete from ScoreEntity t where t.dishId=?1 and t.raterTable=?2")
    int deleteScoreEntitiesByDishIdEqualsAndAndRaterTableEquals(Integer dishId, Integer raterTable);
}
